package com.gitee.ywj1352.leecode;


/**
 * @author wenjie.yang
 * @date 3/8/2020 10:12 PM
 */
public class DFSDemo {


    public static void dfs(int depth, char[] arr,char[] nowArr,boolean[] pb) {
        if (depth == 0){
            String string = new String(nowArr);
            System.out.println(string);
            return;
        }
        depth--;
        for (int i = 0 ;i< arr.length;i++){
            if (!pb[i]){
                nowArr[arr.length - depth - 1] = arr[i];
                pb[i]  = true;
                dfs(depth,arr,nowArr,pb);
                //弹栈的时候要 改变状态
                pb[i]  = false;
            }
        }
    }

    public static void main(String[] args) {
        dfs(3,"ABC".toCharArray(),new char[3],new boolean[3]);
    }
}
